<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"> 
    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <h2>Nova Pergunta - Única Escolha</h2>
            <h:form id="form" acceptcharset="utf-8">
                <p:growl id="msg" life="5000"/>
                <p:panel styleClass="container_24 clearfix " style="background: none; border: none;">
                    <p class="subtitle">Pergunta</p>

                    <p:outputLabel value="Titulo:"  styleClass="grid_3"/> 
                    <p:inputText value="#{managerEditCategory.issues.title}"  styleClass="grid_13"/>

                    <div class="clear"/>
                    <p:outputLabel value="Orientação:"  styleClass="grid_3"/>
                    <p:inputTextarea  value="#{managerEditCategory.issues.orientacion}" styleClass="grid_13"/>

                    <div class="clear"/>
                    <p class="subtitle">Alternativas</p>

                    <p:outputLabel value="Alternativa :"  styleClass="grid_3"/>
                    <p:inputTextarea cols="90" rows="2" 
                                     value="#{managerEditCategory.options.title}"  styleClass="grid_13"/>

                    <div class="clear"/>
                    <p:outputLabel value="Pontos :"  styleClass="grid_3"/>
                    <p:rating value="#{managerEditCategory.options.score}" cancel="true" stars="5"  styleClass="grid_13"/> 

                    <div class="clear"/>
                    <div class="grid_23" style="text-align: center;" >
                        <p:commandButton  icon="ui-icon-circle-plus" value="Adicionar Alternativa"
                                          actionListener="#{managerEditCategory.addOptions()}" update="@form, table"/>
                    </div>
                    <br/>
                    <div class="clear"/>
                    <p:dataTable id="table" var="op" value="#{managerEditCategory.optiones}"
                                 rows="20" styleClass="grid_23 dataTable" style=" font-size: 12px;"
                                 emptyMessage="Nenhuma Alternativa encontrado"
                                 editable="true" >
                        
                        <f:facet name="header">
                            Alternativas
                        </f:facet>
                        <p:column>
                            <p:cellEditor>  
                                <f:facet name="output">  
                                    <h:outputText value="#{op.title}" />  
                                </f:facet>  
                                <f:facet name="input">  
                                    <p:inputText value="#{op.title}" style="width:100%"/>  
                                </f:facet>  
                            </p:cellEditor>  

                        </p:column>
                        <p:column style="width: 100px;">
                            <p:cellEditor>  
                                <f:facet name="output">  
                                    <p:rating value="#{op.score}" readonly="true" />  
                                </f:facet>  
                                <f:facet name="input">  
                                    <p:rating value="#{op.score}" style="width:100%"/>  
                                </f:facet>  
                            </p:cellEditor> 

                        </p:column>
                        <p:column style="width:6%">  
                            <p:rowEditor/>
                        </p:column>  

                    </p:dataTable>  

                    <div class="clear"/>
                    <div class="buttonAction">
                        <p:commandButton value="Salvar" icon="ui-icon-disk" actionListener="#{managerEditCategory.update()}" 
                                         update="@form"   styleClass="ui-priority-primary"/>
                        <p:commandButton value="Cancelar" icon="ui-icon-close" 
                                         actionListener="#{managerEditCategory.redirect('editIssues.xhtml')}"
                                         immediate="true"  />
                    </div>

                </p:panel>

            </h:form>
        </ui:define>
    </ui:composition>
</html>

